{extend name="ace/layout/default" /}

{block name="title"}菜单管理{/block}

{block name="content"}
<h3 class="header smaller lighter blue">
    菜单列表
    <small>
        <i class="icon-double-angle-right"></i>
        AdminMenus list
    </small>
</h3>
<div class="row">
    <?php $parent_id = input('parent_id', 0); ?>
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <a href="{:url('detail') }">
            <button class="btn btn-sm btn-success">
                <i class="icon-zoom-in bigger-120"></i>
                添加菜单
            </button>
        </a>
        {if $parent_id}
        <a href="{:url('detail', ['parent_id' => $parent_id]) }">
            <button class="btn btn-sm btn-success">
                <i class="icon-zoom-in bigger-120"></i>
                添加当前主栏目的子菜单
            </button>
        </a>
        {/if}
    </div>
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <div class="space-4"></div>
        <form action="" method="get" id="form_data" class="first_form float-left">
            <?php $is_check = input('is_check', -1); ?>
            <select name="is_check">
                <option value="-1" {$is_check == -1 ? 'selected' : ''}> 请选择状态 </option>
                <option value="1" {$is_check == 1 ? 'selected' : ''}> 正常 </option>
                <option value="0" {$is_check == 0 ? 'selected' : ''}> 禁用 </option>
            </select>
            <select name="parent_id">
                <option value="0" {$parent_id == 0 ? 'selected' : ''}> 请选择父级栏目 </option>
                {if !empty($menus)}
                    {foreach $menus as $menu}
                        <option value="{$menu['menu_id']}" {$parent_id == $menu['menu_id'] ? 'selected' : ''}> {$menu['menu_name']} </option>
                        {if !empty($menu['_child'])}
                            {foreach $menu['_child'] as $child}
                                <option value="{$child['menu_id']}" {$parent_id == $child['menu_id'] ? 'selected' : ''}>├─{$child['menu_name']} </option>
                            {/foreach}
                        {/if}
                    {/foreach}
                {/if}
            </select>
            <span class="input-icon">
                <button type="button" class="btn btn-purple btn-sm" onclick="$('form.first_form').submit();">
                    Search
                    <i class="icon-search icon-on-right bigger-110"></i>
                </button>
            </span>
        </form>
    </div>
</div>
<div class="space-4"></div>
<div class="table-header">AdminMenus list</div>
<div class="table-responsive">
    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="center">
                <label>
                    <input type="checkbox" class="ace" name="menu_id[]" />
                    <span class="lbl"></span>
                </label>
            </th>
            <th class="text-center"> Id </th>
            <th class="text-center"> 菜单名称 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 排序 </th>
            <th class="text-center hidden-sm hidden-xs"> 是否左侧展示 </th>
            <th class="text-center"> 状态 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 创建时间 </th>
            <th class="text-center"> 操作 </th>
        </tr>
        </thead>
        <tbody>
        {if !empty($list) && $list->total()}
        {foreach $list as $key => $item}
        <tr id="id_{$item->menu_id}" name="{$item->menu_name}">
            <td class="text-center">
                <label>
                    <input type="checkbox" class="ace" name="menu_id[]" value="{$item->menu_id}" />
                    <span class="lbl"></span>
                </label>
            </td>
            <td class="text-center"> <a href="javascript:;">{$item->menu_id}</a> </td>
            <td class="text-center"> {$item->menu_name} </td>
            <td class="text-center hidden-sm hidden-xs hidden-md"> {$item->menu_sort} </td>
            <td class="text-center hidden-sm hidden-xs">
                {switch $item->is_left|intval }
                {case 1}
                <span class="label label-success"> 是 </span>
                {/case}
                {default /}
                <span class="label label-danger"> 否 </span>
                {/switch}
            </td>
            <td class="text-center">
                {switch $item->is_check|intval }
                {case 1}
                <span class="label label-success"> 正常 </span>
                {/case}
                {default /}
                <span class="label label-danger"> 禁用 </span>
                {/switch}
            </td>
            <td class="text-center hidden-sm hidden-xs hidden-md">
                {:date('Y-m-d H:i', $item->created_time)}
            </td>
            <td class="text-center">
                <div class="hidden-sm hidden-xs action-buttons">
                    {switch $item->is_left|intval }
                    {case 1}
                    <a class="btn btn-xs btn-danger" title="隐藏栏目“{$item->menu_name}”" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_left', 'change_value':0})">
                        <i class="icon-eye-close bigger-120"></i> 隐藏栏目
                    </a>
                    {/case}
                    {default /}
                    <a class="btn btn-xs btn-success" title="启用栏目“{$item->menu_name}”展示" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_left', 'change_value':1})">
                        <i class="icon-eye-open bigger-120"></i> 展示栏目
                    </a>
                    {/switch}

                    {switch $item->is_check|intval }
                    {case 1}
                        <a class="btn btn-xs btn-danger" title="禁用“{$item->menu_name}”菜单" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_check', 'change_value':0})">
                            <i class="icon-lock bigger-120"></i> 禁用
                        </a>
                    {/case}
                    {default /}
                        <a class="btn btn-xs btn-success" title="启用“{$item->menu_name}”菜单" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_check', 'change_value':1})">
                            <i class="icon-unlock bigger-120"></i> 启用
                        </a>
                    {/switch}

                    <a class="btn btn-xs btn-info" title="编辑“{$item->menu_name}”菜单" href="{:url('detail', ['menu_id' => $item->menu_id])}">
                        <i class="icon-edit bigger-120"></i> 编辑
                    </a>
                    <a class="btn btn-xs btn-danger" title="删除“{$item->menu_name}”<菜单" onclick="delOperation({$item->menu_id}, '{:url(\'delete\')}')">
                        <i class="icon-trash bigger-120"></i> 删除
                    </a>
                </div>
                <div class="hidden-md hidden-lg">
                    <div class="inline position-relative">
                        <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                            <i class="icon-cog bigger-110"></i>
                        </button>
                        <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                            {switch $item->is_left|intval }
                            {case 1}
                            <li>
                                <a class="btn btn-xs btn-danger" title="隐藏栏目“{$item->menu_name}”" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_left', 'change_value':0})">
                                    <i class="icon-eye-close bigger-120"></i> 隐藏栏目
                                </a>
                                <div class="hr hr-dotted"></div>
                            </li>
                            {/case}
                            {default /}
                            <li>
                                <a class="btn btn-xs btn-success" title="启用栏目“{$item->menu_name}”展示" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_left', 'change_value':1})">
                                    <i class="icon-eye-open bigger-120"></i> 展示栏目
                                </a>
                                <div class="hr hr-dotted"></div>
                            </li>
                            {/switch}                            

                            {switch $item->is_check|intval }
                            {case 1}
                            <li>
                                <a class="btn btn-xs btn-danger" title="禁用“{$item->menu_name}”菜单" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_check', 'change_value':0})">
                                    <i class="icon-lock bigger-120"></i> 禁用
                                </a>
                                <div class="hr hr-dotted"></div>
                            </li>
                            {/case}
                            {default /}
                            <li>
                                <a class="btn btn-xs btn-success" title="启用“{$item->menu_name}”菜单" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'menu_id' : '{$item->menu_id}', 'change_field' : 'is_check', 'change_value':1})">
                                    <i class="icon-unlock bigger-120"></i> 启用
                                </a>
                                <div class="hr hr-dotted"></div>
                            </li>
                            {/switch}

                            <li>
                                <a class="btn btn-xs btn-info" title="编辑“{$item->menu_name}”菜单" href="{:url('detail', ['menu_id' => $item->menu_id])}">
                                    <i class="icon-edit bigger-120"></i> 编辑
                                </a>
                            </li>
                            <li>
                                <div class="hr hr-dotted"></div>
                                <a class="btn btn-xs btn-danger" title="删除“{$item->menu_name}”菜单" onclick="delOperation({$item->menu_id}, '{:url(\'delete\')}')">
                                    <i class="icon-trash bigger-120"></i> 删除
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </td>
        </tr>
        {/foreach}
        {/if}
        </tbody>
    </table>

    <div class="hr hr-18 dotted hr-double"></div>
</div><!-- /.table-responsive -->
{/block}